<template>
  <d2-container>
    <div class="flex-1 mx-2 mt-2 row-ac-fw">
      <!-- 地区 -->
      <div class="types-box">
        <div class="my-1">
          <div class="ml-2">
            <el-button type="primary" size="mini" @click="addAreaOpen">添加地区</el-button>
          </div>
        </div>
        <div class="flex-1 mx-1">
          <el-table :data="areaList" stripe>
            <el-table-column align="center" label="序号" type="index" width="40" />
            <el-table-column label="地区" prop="area_name" width="70" />
            <el-table-column align="center" label="操作" width="60">
              <template slot-scope="scope">
                <i class="el-icon-edit mr-1 cp" @click="areaHandleEdit(scope.row.id)"></i>
                <i class="el-icon-delete cp" @click="areaOpenDelete(scope.row.id)"></i>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!-- 课程 -->
      <div class="types-box">
        <div class="my-1">
          <div class="ml-2">
            <el-button type="primary" size="mini" @click="addCourseOpen">添加课程</el-button>
          </div>
        </div>
        <div class="flex-1 mx-1">
          <el-table :data="courseList" stripe>
            <el-table-column align="center" label="序号" type="index" width="40" />
            <el-table-column label="课程" prop="course_name" width="70" />
            <el-table-column align="center" label="操作" width="60">
              <template slot-scope="scope">
                <i class="el-icon-edit mr-1 cp" @click="courseHandleEdit(scope.row.id)"></i>
                <i class="el-icon-delete cp" @click="courseOpenDelete(scope.row.id)"></i>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!-- 版本 -->
      <div class="types-box">
        <div class="my-1">
          <div class="ml-2">
            <el-button type="primary" size="mini" @click="addEditionOpen">添加版本</el-button>
          </div>
        </div>
        <div class="flex-1 mx-1">
          <el-table :data="editionList" stripe>
            <el-table-column align="center" label="序号" type="index" width="40" />
            <el-table-column label="版本" prop="edition_name" width="70" />
            <el-table-column align="center" label="操作" width="60">
              <template slot-scope="scope">
                <i class="el-icon-edit mr-1 cp" @click="editionHandleEdit(scope.row.id)"></i>
                <i class="el-icon-delete cp" @click="editionOpenDelete(scope.row.id)"></i>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!-- 内容 -->
      <div class="types-box">
        <div class="my-1">
          <div class="ml-2">
            <el-button type="primary" size="mini" @click="addSubstanceOpen">添加内容</el-button>
          </div>
        </div>
        <div class="flex-1 mx-1">
          <el-table :data="substanceList" stripe>
            <el-table-column align="center" label="序号" type="index" width="40" />
            <el-table-column label="内容" prop="substance_name" width="70" />
            <el-table-column align="center" label="操作" width="60">
              <template slot-scope="scope">
                <i class="el-icon-edit mr-1 cp" @click="substanceHandleEdit(scope.row.id)"></i>
                <i class="el-icon-delete cp" @click="substanceOpenDelete(scope.row.id)"></i>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!-- 段级 -->
      <div class="types-box">
        <div class="my-1">
          <div class="ml-2">
            <el-button type="primary" size="mini" @click="addSegmentOpen">添加段级</el-button>
          </div>
        </div>
        <div class="flex-1 mx-1">
          <el-table :data="segmentList" stripe>
            <el-table-column align="center" label="序号" type="index" width="40" />
            <el-table-column label="段级" prop="segment_name" width="70" />
            <el-table-column align="center" label="操作" width="60">
              <template slot-scope="scope">
                <i class="el-icon-edit mr-1 cp" @click="segmentHandleEdit(scope.row.id)"></i>
                <i class="el-icon-delete cp" @click="segmentOpenDelete(scope.row.id)"></i>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!-- 学期 -->
      <div class="types-box">
        <div class="my-1">
          <div class="ml-2">
            <el-button type="primary" size="mini" @click="addSemesterOpen">添加学期</el-button>
          </div>
        </div>
        <div class="flex-1 mx-1">
          <el-table :data="semesterList" stripe>
            <el-table-column align="center" label="序号" type="index" width="40" />
            <el-table-column label="学期" prop="semester_name" width="70" />
            <el-table-column align="center" label="操作" width="60">
              <template slot-scope="scope">
                <i class="el-icon-edit mr-1 cp" @click="semesterHandleEdit(scope.row.id)"></i>
                <i class="el-icon-delete cp" @click="semesterOpenDelete(scope.row.id)"></i>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!-- 难度 -->
      <div class="types-box">
        <div class="my-1">
          <div class="ml-2">
            <el-button type="primary" size="mini" @click="addDifficultyOpen">添加程度</el-button>
          </div>
        </div>
        <div class="flex-1 mx-1">
          <el-table :data="difficultyList" stripe>
            <el-table-column align="center" label="序号" type="index" width="40" />
            <el-table-column label="程度" prop="difficulty_name" width="70" />
            <el-table-column align="center" label="操作" width="60">
              <template slot-scope="scope">
                <i class="el-icon-edit mr-1 cp" @click="difficultyHandleEdit(scope.row.id)"></i>
                <i class="el-icon-delete cp" @click="difficultyOpenDelete(scope.row.id)"></i>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!-- 综合 -->
      <div class="types-box">
        <div class="my-1">
          <div class="ml-2">
            <el-button type="primary" size="mini" @click="addSynthesizeOpen">添加综合</el-button>
          </div>
        </div>
        <div class="flex-1 mx-1">
          <el-table :data="synthesizeList" stripe>
            <el-table-column align="center" label="序号" type="index" width="40" />
            <el-table-column label="综合" prop="synthesize_name" width="70" />
            <el-table-column align="center" label="操作" width="60">
              <template slot-scope="scope">
                <i class="el-icon-edit mr-1 cp" @click="synthesizeHandleEdit(scope.row.id)"></i>
                <i class="el-icon-delete cp" @click="synthesizeOpenDelete(scope.row.id)"></i>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>
    <!-- 地区 -->
    <el-dialog :visible.sync="dialogAreaVisible" width="30%" title="添加/修改地区">
      <el-form :model="formArea" ref="form" label-width="80px">
        <el-form-item label="地区" prop="course_name">
          <div style="width: 50%;">
            <el-input v-model="formArea.area_name"></el-input>
          </div>
        </el-form-item>
        <el-form-item label="排序" prop="sort">
          <div style="width: 18%;">
            <el-input v-model="formArea.sort"></el-input>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogAreaVisible = false">取 消</el-button>
        <el-button type="primary" v-if="!addAreaStata" @click="submitAreaForm">修改</el-button>
        <el-button type="primary" v-if="addAreaStata" @click="addAreaForm">保存</el-button>
      </div>
    </el-dialog>
    <!-- 课程 -->
    <el-dialog :visible.sync="dialogCourseVisible" width="30%" title="添加/修改课程">
      <el-form :model="formCourse" ref="form" label-width="80px">
        <el-form-item label="课程" prop="course_name">
          <div style="width: 50%;">
            <el-input v-model="formCourse.course_name"></el-input>
          </div>
        </el-form-item>
        <el-form-item label="排序" prop="sort">
          <div style="width: 18%;">
            <el-input v-model="formCourse.sort"></el-input>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogCourseVisible = false">取 消</el-button>
        <el-button type="primary" v-if="!addCourseStata" @click="submitCourseForm">修改</el-button>
        <el-button type="primary" v-if="addCourseStata" @click="addCourseForm">保存</el-button>
      </div>
    </el-dialog>
    <!-- 版本 -->
    <el-dialog :visible.sync="dialogEditionVisible" width="30%" title="添加/修改版本">
      <el-form :model="formEdition" ref="form" label-width="80px">
        <el-form-item label="课程" prop="edition_name">
          <div style="width: 50%;">
            <el-input v-model="formEdition.edition_name"></el-input>
          </div>
        </el-form-item>
        <el-form-item label="排序" prop="sort">
          <div style="width: 18%;">
            <el-input v-model="formEdition.sort"></el-input>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogEditionVisible = false">取 消</el-button>
        <el-button type="primary" v-if="!addEditionStata" @click="submitEditionForm">修改</el-button>
        <el-button type="primary" v-if="addEditionStata" @click="addEditionForm">保存</el-button>
      </div>
    </el-dialog>
    <!-- 内容 -->
    <el-dialog :visible.sync="dialogSubstanceVisible" width="30%" title="添加/修改内容">
      <el-form :model="formSubstance" ref="form" label-width="80px">
        <el-form-item label="内容" prop="substance_name">
          <div style="width: 50%;">
            <el-input v-model="formSubstance.substance_name"></el-input>
          </div>
        </el-form-item>
        <el-form-item label="排序" prop="sort">
          <div style="width: 18%;">
            <el-input v-model="formSubstance.sort"></el-input>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogSubstanceVisible = false">取 消</el-button>
        <el-button type="primary" v-if="!addSubstanceStata" @click="submitSubstanceForm">修改</el-button>
        <el-button type="primary" v-if="addSubstanceStata" @click="addSubstanceForm">保存</el-button>
      </div>
    </el-dialog>
    <!-- 段级 -->
    <el-dialog :visible.sync="dialogSegmentVisible" width="30%" title="添加/修改段级">
      <el-form :model="formSegment" ref="form" label-width="80px">
        <el-form-item label="段级" prop="segment_name">
          <div style="width: 50%;">
            <el-input v-model="formSegment.segment_name"></el-input>
          </div>
        </el-form-item>
        <el-form-item label="排序" prop="sort">
          <div style="width: 18%;">
            <el-input v-model="formSegment.sort"></el-input>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogSegmentVisible = false">取 消</el-button>
        <el-button type="primary" v-if="!addSegmentStata" @click="submitSegmentForm">修改</el-button>
        <el-button type="primary" v-if="addSegmentStata" @click="addSegmentForm">保存</el-button>
      </div>
    </el-dialog>
    <!-- 学期 -->
    <el-dialog :visible.sync="dialogSemesterVisible" width="30%" title="添加/修改学期">
      <el-form :model="formSemester" ref="form" label-width="80px">
        <el-form-item label="学期" prop="semester_name">
          <div style="width: 50%;">
            <el-input v-model="formSemester.semester_name"></el-input>
          </div>
        </el-form-item>
        <el-form-item label="排序" prop="sort">
          <div style="width: 18%;">
            <el-input v-model="formSemester.sort"></el-input>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogSemesterVisible = false">取 消</el-button>
        <el-button type="primary" v-if="!addSemesterStata" @click="submitSemesterForm">修改</el-button>
        <el-button type="primary" v-if="addSemesterStata" @click="addSemesterForm">保存</el-button>
      </div>
    </el-dialog>
    <!-- 程度 -->
    <el-dialog :visible.sync="dialogDifficultyVisible" width="30%" title="添加/修改程度">
      <el-form :model="formDifficulty" ref="form" label-width="80px">
        <el-form-item label="程度" prop="difficulty_name">
          <div style="width: 50%;">
            <el-input v-model="formDifficulty.difficulty_name"></el-input>
          </div>
        </el-form-item>
        <el-form-item label="排序" prop="sort">
          <div style="width: 18%;">
            <el-input v-model="formDifficulty.sort"></el-input>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogDifficultyVisible = false">取 消</el-button>
        <el-button type="primary" v-if="!addDifficultyStata" @click="submitDifficultyForm">修改</el-button>
        <el-button type="primary" v-if="addDifficultyStata" @click="addDifficultyForm">保存</el-button>
      </div>
    </el-dialog>
    <!-- 综合 -->
    <el-dialog :visible.sync="dialogSynthesizeVisible" width="30%" title="添加/修改综合">
      <el-form :model="formSynthesize" ref="form" label-width="80px">
        <el-form-item label="综合" prop="synthesize_name">
          <div style="width: 50%;">
            <el-input v-model="formSynthesize.synthesize_name"></el-input>
          </div>
        </el-form-item>
        <el-form-item label="排序" prop="sort">
          <div style="width: 18%;">
            <el-input v-model="formSynthesize.sort"></el-input>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogSynthesizeVisible = false">取 消</el-button>
        <el-button type="primary" v-if="!addSynthesizeStata" @click="submitSynthesizeForm">修改</el-button>
        <el-button type="primary" v-if="addSynthesizeStata" @click="addSynthesizeForm">保存</el-button>
      </div>
    </el-dialog>
  </d2-container>
</template>

<script>
  import {
    areaDeleteUrl,
    areaUpdateUrl,
    areaCreateUrl,
    areaDetailUrl,
    areaListUrl,
    courseDeleteUrl,
    courseUpdateUrl,
    courseCreateUrl,
    courseDetailUrl,
    courseListUrl,
    editionDeleteUrl,
    editionUpdateUrl,
    editionCreateUrl,
    editionDetailUrl,
    editionListUrl,
    substanceDeleteUrl,
    substanceUpdateUrl,
    substanceCreateUrl,
    substanceDetailUrl,
    substanceListUrl,
    segmentDeleteUrl,
    segmentUpdateUrl,
    segmentCreateUrl,
    segmentDetailUrl,
    segmentListUrl,
    semesterDeleteUrl,
    semesterUpdateUrl,
    semesterCreateUrl,
    semesterDetailUrl,
    semesterListUrl,
    difficultyDeleteUrl,
    difficultyUpdateUrl,
    difficultyCreateUrl,
    difficultyDetailUrl,
    difficultyListUrl,
    synthesizeDeleteUrl,
    synthesizeUpdateUrl,
    synthesizeCreateUrl,
    synthesizeDetailUrl,
    synthesizeListUrl
  } from '@/utils/answer'
  export default {
    data() {
      return {
        //地区
        areaList: [],
        dialogAreaVisible: false,
        addAreaStata: false,
        takeAreaId: '',
        formArea: {
          area_name: '',
          sort: 0
        },
        //课程
        courseList: [],
        dialogCourseVisible: false,
        addCourseStata: false,
        takeCourseId: '',
        formCourse: {
          course_name: '',
          sort: 0
        },
        //版本
        editionList: [],
        dialogEditionVisible: false,
        addEditionStata: false,
        takeEditionId: '',
        formEdition: {
          edition_name: '',
          sort: 0
        },
        //内容
        substanceList: [],
        dialogSubstanceVisible: false,
        addSubstanceStata: false,
        takeSubstanceId: '',
        formSubstance: {
          substance_name: '',
          sort: 0
        },
        //段级
        segmentList: [],
        dialogSegmentVisible: false,
        addSegmentStata: false,
        takeSegmentId: '',
        formSegment: {
          segment_name: '',
          sort: 0
        },
        //学期
        semesterList: [],
        dialogSemesterVisible: false,
        addSemesterStata: false,
        takeSemesterId: '',
        formSemester: {
          semester_name: '',
          sort: 0
        },
        //程度
        difficultyList: [],
        dialogDifficultyVisible: false,
        addDifficultyStata: false,
        takeDifficultyId: '',
        formDifficulty: {
          difficulty_name: '',
          sort: 0
        },
        //综合
        synthesizeList: [],
        dialogSynthesizeVisible: false,
        addSynthesizeStata: false,
        takeSynthesizeId: '',
        formSynthesize: {
          synthesize_name: '',
          sort: 0
        }
      }
    },
    created() {
      this.getAreaList()
      this.getCourseList()
      this.getEditionList()
      this.getSubstanceList()
      this.getSegmentList()
      this.getSemesterList()
      this.getDifficultyList()
      this.getSynthesizeList()
    },
    methods: {
      //地区
      getAreaList() {
        this.$get(areaListUrl).then(res => {
          this.areaList = res.data.data.list
        })
      },
      addAreaOpen() {
        this.addAreaStata = true
        this.dialogAreaVisible = true
      },
      addAreaForm() {
        this.$post(areaCreateUrl, this.formArea).then(res => {
          if (res.data.code == 200) {
            this.dialogAreaVisible = false
            this.formArea = {}
            this.$message({
              type: 'success',
              message: '添加成功!'
            });
            this.getAreaList()
          }
        })
      },
      areaHandleEdit(areaId) {
        this.addAreaStata = false
        this.dialogAreaVisible = true
        this.takeAreaId = areaId
        this.$get(areaDetailUrl + areaId + '/').then(res => {
          this.formArea = {
            area_name: res.data.data.area_name,
            sort: res.data.data.sort,
          }
        })
      },
      submitAreaForm() {
        this.$put(areaUpdateUrl + this.takeAreaId + '/', this.formArea).then(res => {
          if (res.data.code == 200) {
            this.dialogAreaVisible = false
            this.formArea = {}
            this.$message({
              type: 'success',
              message: '修改成功!'
            });
            this.getAreaList()
          }
        })
      },
      areaOpenDelete(areaId) {
        this.$confirm('此操作将删除该地区?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$del(areaDeleteUrl + areaId + '/').then(res => {
            if (res.data.code == 200) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
              this.getAreaList()
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消修改'
          });
        });
      },
      //课程
      getCourseList() {
        this.$get(courseListUrl).then(res => {
          this.courseList = res.data.data.list
        })
      },
      addCourseOpen() {
        this.addCourseStata = true
        this.dialogCourseVisible = true
      },
      addCourseForm() {
        this.$post(courseCreateUrl, this.formCourse).then(res => {
          if (res.data.code == 200) {
            this.dialogCourseVisible = false
            this.formCourse = {}
            this.$message({
              type: 'success',
              message: '添加成功!'
            });
            this.getCourseList()
          }
        })
      },
      courseHandleEdit(courseId) {
        this.addCourseStata = false
        this.dialogCourseVisible = true
        this.takeCourseId = courseId
        this.$get(courseDetailUrl + courseId + '/').then(res => {
          this.formCourse = {
            course_name: res.data.data.course_name,
            sort: res.data.data.sort,
          }
        })
      },
      submitCourseForm() {
        this.$put(courseUpdateUrl + this.takeCourseId + '/', this.formCourse).then(res => {
          if (res.data.code == 200) {
            this.dialogCourseVisible = false
            this.formCourse = {}
            this.$message({
              type: 'success',
              message: '修改成功!'
            });
            this.getCourseList()
          }
        })
      },
      courseOpenDelete(courseId) {
        this.$confirm('此操作将删除该课程?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$del(courseDeleteUrl + courseId + '/').then(res => {
            if (res.data.code == 200) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
              this.getCourseList()
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消修改'
          });
        });
      },
      //版本
      getEditionList() {
        this.$get(editionListUrl).then(res => {
          this.editionList = res.data.data.list
        })
      },
      addEditionOpen() {
        this.addEditionStata = true
        this.dialogEditionVisible = true
      },
      addEditionForm() {
        this.$post(editionCreateUrl, this.formEdition).then(res => {
          if (res.data.code == 200) {
            this.dialogEditionVisible = false
            this.formEdition = {}
            this.$message({
              type: 'success',
              message: '添加成功!'
            });
            this.getEditionList()
          }
        })
      },
      editionHandleEdit(editionId) {
        this.addEditionStata = false
        this.dialogEditionVisible = true
        this.takeEditionId = editionId
        this.$get(editionDetailUrl + editionId + '/').then(res => {
          this.formEdition = {
            edition_name: res.data.data.edition_name,
            sort: res.data.data.sort,
          }
        })
      },
      submitEditionForm() {
        this.$put(editionUpdateUrl + this.takeEditionId + '/', this.formEdition).then(res => {
          if (res.data.code == 200) {
            this.dialogEditionVisible = false
            this.formEdition = {}
            this.$message({
              type: 'success',
              message: '修改成功!'
            });
            this.getEditionList()
          }
        })
      },
      editionOpenDelete(editionId) {
        this.$confirm('此操作将删除该版本?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$del(editionDeleteUrl + editionId + '/').then(res => {
            if (res.data.code == 200) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
              this.getEditionList()
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消修改'
          });
        });
      },
      //内容
      getSubstanceList() {
        this.$get(substanceListUrl).then(res => {
          this.substanceList = res.data.data.list
        })
      },
      addSubstanceOpen() {
        this.addSubstanceStata = true
        this.dialogSubstanceVisible = true
      },
      addSubstanceForm() {
        this.$post(substanceCreateUrl, this.formSubstance).then(res => {
          if (res.data.code == 200) {
            this.dialogSubstanceVisible = false
            this.formSubstance = {}
            this.$message({
              type: 'success',
              message: '添加成功!'
            });
            this.getSubstanceList()
          }
        })
      },
      substanceHandleEdit(substanceId) {
        this.addSubstanceStata = false
        this.dialogSubstanceVisible = true
        this.takeSubstanceId = substanceId
        this.$get(substanceDetailUrl + substanceId + '/').then(res => {
          this.formSubstance = {
            substance_name: res.data.data.substance_name,
            sort: res.data.data.sort,
          }
        })
      },
      submitSubstanceForm() {
        this.$put(substanceUpdateUrl + this.takeSubstanceId + '/', this.formSubstance).then(res => {
          if (res.data.code == 200) {
            this.dialogSubstanceVisible = false
            this.formSubstance = {}
            this.$message({
              type: 'success',
              message: '修改成功!'
            });
            this.getSubstanceList()
          }
        })
      },
      substanceOpenDelete(substanceId) {
        this.$confirm('此操作将删除该内容?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$del(substanceDeleteUrl + substanceId + '/').then(res => {
            if (res.data.code == 200) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
              this.getSubstanceList()
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消修改'
          });
        });
      },
      //段级
      getSegmentList() {
        this.$get(segmentListUrl).then(res => {
          this.segmentList = res.data.data.list
        })
      },
      addSegmentOpen() {
        this.addSegmentStata = true
        this.dialogSegmentVisible = true
      },
      addSegmentForm() {
        this.$post(segmentCreateUrl, this.formSegment).then(res => {
          if (res.data.code == 200) {
            this.dialogSegmentVisible = false
            this.formSegment = {}
            this.$message({
              type: 'success',
              message: '添加成功!'
            });
            this.getSegmentList()
          }
        })
      },
      segmentHandleEdit(segmentId) {
        this.addSegmentStata = false
        this.dialogSegmentVisible = true
        this.takeSegmentId = segmentId
        this.$get(segmentDetailUrl + segmentId + '/').then(res => {
          this.formSegment = {
            segment_name: res.data.data.segment_name,
            sort: res.data.data.sort,
          }
        })
      },
      submitSegmentForm() {
        this.$put(segmentUpdateUrl + this.takeSegmentId + '/', this.formSegment).then(res => {
          if (res.data.code == 200) {
            this.dialogSegmentVisible = false
            this.formSegment = {}
            this.$message({
              type: 'success',
              message: '修改成功!'
            });
            this.getSegmentList()
          }
        })
      },
      segmentOpenDelete(segmentId) {
        this.$confirm('此操作将删除该段级?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$del(segmentDeleteUrl + segmentId + '/').then(res => {
            if (res.data.code == 200) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
              this.getSegmentList()
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消修改'
          });
        });
      },
      //学期
      getSemesterList() {
        this.$get(semesterListUrl).then(res => {
          this.semesterList = res.data.data.list
        })
      },
      addSemesterOpen() {
        this.addSemesterStata = true
        this.dialogSemesterVisible = true
      },
      addSemesterForm() {
        this.$post(semesterCreateUrl, this.formSemester).then(res => {
          if (res.data.code == 200) {
            this.dialogSemesterVisible = false
            this.formSemester = {}
            this.$message({
              type: 'success',
              message: '添加成功!'
            });
            this.getSemesterList()
          }
        })
      },
      semesterHandleEdit(semesterId) {
        this.addSemesterStata = false
        this.dialogSemesterVisible = true
        this.takeSemesterId = semesterId
        this.$get(semesterDetailUrl + semesterId + '/').then(res => {
          this.formSemester = {
            semester_name: res.data.data.semester_name,
            sort: res.data.data.sort,
          }
        })
      },
      submitSemesterForm() {
        this.$put(semesterUpdateUrl + this.takeSemesterId + '/', this.formSemester).then(res => {
          if (res.data.code == 200) {
            this.dialogSemesterVisible = false
            this.formSemester = {}
            this.$message({
              type: 'success',
              message: '修改成功!'
            });
            this.getSemesterList()
          }
        })
      },
      semesterOpenDelete(semesterId) {
        this.$confirm('此操作将删除该学期?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$del(semesterDeleteUrl + semesterId + '/').then(res => {
            if (res.data.code == 200) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
              this.getSemesterList()
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消修改'
          });
        });
      },
      //难度
      getDifficultyList() {
        this.$get(difficultyListUrl).then(res => {
          this.difficultyList = res.data.data.list
        })
      },
      addDifficultyOpen() {
        this.addDifficultyStata = true
        this.dialogDifficultyVisible = true
      },
      addDifficultyForm() {
        this.$post(difficultyCreateUrl, this.formDifficulty).then(res => {
          if (res.data.code == 200) {
            this.dialogDifficultyVisible = false
            this.formDifficulty = {}
            this.$message({
              type: 'success',
              message: '添加成功!'
            });
            this.getDifficultyList()
          }
        })
      },
      difficultyHandleEdit(difficultyId) {
        this.addDifficultyStata = false
        this.dialogDifficultyVisible = true
        this.takeDifficultyId = difficultyId
        this.$get(difficultyDetailUrl + difficultyId + '/').then(res => {
          this.formDifficulty = {
            difficulty_name: res.data.data.difficulty_name,
            sort: res.data.data.sort,
          }
        })
      },
      submitDifficultyForm() {
        this.$put(difficultyUpdateUrl + this.takeDifficultyId + '/', this.formDifficulty).then(res => {
          if (res.data.code == 200) {
            this.dialogDifficultyVisible = false
            this.formDifficulty = {}
            this.$message({
              type: 'success',
              message: '修改成功!'
            });
            this.getDifficultyList()
          }
        })
      },
      difficultyOpenDelete(difficultyId) {
        this.$confirm('此操作将删除该学期?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$del(difficultyDeleteUrl + difficultyId + '/').then(res => {
            if (res.data.code == 200) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
              this.getDifficultyList()
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消修改'
          });
        });
      },
      //综合
      getSynthesizeList() {
        this.$get(synthesizeListUrl).then(res => {
          this.synthesizeList = res.data.data.list
        })
      },
      addSynthesizeOpen() {
        this.addSynthesizeStata = true
        this.dialogSynthesizeVisible = true
      },
      addSynthesizeForm() {
        this.$post(synthesizeCreateUrl, this.formSynthesize).then(res => {
          if (res.data.code == 200) {
            this.dialogSynthesizeVisible = false
            this.formSynthesize = {}
            this.$message({
              type: 'success',
              message: '添加成功!'
            });
            this.getSynthesizeList()
          }
        })
      },
      synthesizeHandleEdit(synthesizeId) {
        this.addSynthesizeStata = false
        this.dialogSynthesizeVisible = true
        this.takeSynthesizeId = synthesizeId
        this.$get(synthesizeDetailUrl + synthesizeId + '/').then(res => {
          this.formSynthesize = {
            synthesize_name: res.data.data.synthesize_name,
            sort: res.data.data.sort,
          }
        })
      },
      submitSynthesizeForm() {
        this.$put(synthesizeUpdateUrl + this.takeSynthesizeId + '/', this.formSynthesize).then(res => {
          if (res.data.code == 200) {
            this.dialogSynthesizeVisible = false
            this.formSynthesize = {}
            this.$message({
              type: 'success',
              message: '修改成功!'
            });
            this.getSynthesizeList()
          }
        })
      },
      synthesizeOpenDelete(synthesizeId) {
        this.$confirm('此操作将删除该学期?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$del(synthesizeDeleteUrl + synthesizeId + '/').then(res => {
            if (res.data.code == 200) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
              this.getSynthesizeList()
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消修改'
          });
        });
      }
    }
  }
</script>

<style>
  .types-box {
    width: 23%;
    margin-right: 2%;
    height: 500px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)
  }
</style>
